NSGeometry: complete NSIntegralRectWithOptions#700
Merged
Conversation
The function ignored the width and height options, always aligned both the minimum and maximum edge of each axis, did not handle NSAlignRectFlipped and collapsed an empty rectangle to the zero rect. Align each axis from exactly two of its minimum edge, maximum edge and size, raising NSInvalidArgumentException otherwise; round a nearest tie towards positive infinity, or negative infinity for a flipped edge; and align an empty or zero-size rectangle in place rather than discarding it. Behaviour checked against Apple Foundation.
Member
|
With that change in place you could rewrite your gui change to use this function. |
Contributor
Author
|
Thanks. Once this is in, I will rewrite -[NSView backingAlignedRect:options:] to call NSIntegralRectWithOptions instead of the private alignment helper it uses now. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
NSIntegralRectWithOptions did not implement its full contract:
Each axis is now aligned from exactly two of its minimum edge, maximum edge and size (raising NSInvalidArgumentException otherwise); an inward option rounds an edge toward the interior of the rectangle, outward away from it, nearest to the closest unit with a tie towards positive infinity (negative infinity for a Y edge under NSAlignRectFlipped); and an empty or zero-size rectangle keeps its aligned origin.
Every option combination, the flipped tie, the empty/zero-size handling and the exception were checked against Apple Foundation on a macOS runner. The behaviour is exercised by a new NSIntegralRectWithOptions set in Tests/base/Functions/NSGeometry2.m (7 of its assertions fail against the previous implementation).